/*
 * Copied from: http://stackoverflow.com/questions/20146/how-to-create-a-temporary-file-for-writing-to-in-c 
 * in 01/05/2012
 * */
public sealed class TemporaryFile : IDisposable {
	public TemporaryFile() : 
		this(Path.GetTempPath()) { }

	public TemporaryFile(string directory) {
		Create(Path.Combine(directory, Path.GetRandomFileName()));
	}

	~TemporaryFile() {
		Delete();
	}

	public void Dispose() {
		Delete();
		GC.SuppressFinalize(this);
	}

	public string FilePath { get; private set; }

	private void Create(string path) {
		FilePath = path;
		using (File.Create(FilePath)) { };
	}

	private void Delete() {
		if (FilePath == null) return;
		File.Delete(FilePath);
		FilePath = null;
	}
}
